package com.example.im;

import com.example.im.netty.WebSocketServerHandler;
import com.example.im.service.GroupService;
import com.example.im.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class ImApplication {

    @Autowired
    private MessageService messageService;  // ✅ 注入 MessageService
    @Autowired
    private GroupService groupService;

    public static void main(String[] args) {
        SpringApplication.run(ImApplication.class, args);
    }

    @PostConstruct
    public void init() {
        // ✅ 启动完成后，设置到 WebSocketHandler 中
        WebSocketServerHandler.setMessageService(messageService);
        WebSocketServerHandler.setGroupService(groupService);
    }
}